package com.project.controller;

import com.project.bean.UserBean;
import com.project.util.UploadUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLDecoder;

@RestController
@RequestMapping("upload")
public class UploadController {

    @RequestMapping("add")
    public String add(UserBean user,@RequestParam("face") MultipartFile mf) throws Exception {
        String fileName = UploadUtil.upload(mf, "static/html/img");

        user.setImgPath(fileName);
        System.out.println(user);
    return "ok";
    }
}
